package com.duan.laugh.sms.core;


import java.util.List;

/**
 * 配置文件中的短信账户
 *
 * @author duanjw
 */
public class PropertiesSmsAccountLocator implements SmsAccountLocator {
    private SmsAccessProperties emailProperties;

    public PropertiesSmsAccountLocator(SmsAccessProperties smsAccessProperties) {
        this.emailProperties = smsAccessProperties;
    }

    /**
     * 所有短信账户
     * @return
     */
    @Override
    public List<SmsAccount> getSmsAccounts() {
        return emailProperties.getAccounts();
    }

    /**
     * 根据短信账户id获取短信账户
     * @param id
     * @return
     */
    @Override
    public SmsAccount getSmsAccount(String id) {
        return emailProperties.getAccounts().stream().filter(r -> r.getId().equals(id)).findFirst().orElse(null);
    }
}
